package com.xuecheng.content.feignclient;

import com.xuecheng.content.config.MultipartSupportConfig;
import com.xuecheng.media.model.dto.UploadFileResultDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@FeignClient(value = "media-api",
        configuration = {MultipartSupportConfig.class},
fallbackFactory = MediaServiceFeignClientFallback.class)
public interface MediaServiceFeignClient {
    @ApiOperation("上传图片")
    @PostMapping(value = "/media/upload/coursefile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    UploadFileResultDto uploadCoursePic(@RequestPart("filedata") MultipartFile filedata,
                                        @RequestParam(value = "objectName", required = false) String objectName) throws IOException;
}
